package com.spc.demo.constant;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author pingchao.su
 * @date 2022/7/12 19:55
 */
public class Constant {
    // 线程池
    public static final ExecutorService executorService = Executors.newSingleThreadExecutor();

    // 此时返回一个未完成的实例 查看源码调用线程池后直接返回实例，此时该实例还没有完成
    public static final CompletableFuture<String> cf = CompletableFuture.supplyAsync(() -> {
        String content = "hello world";
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return content;
    });
}
